Extend scheme validation to inner schemes of jar: URLs#636
Merged
Conversation
Builds on #633 by recursively validating the inner URL of a jar: URL against the same scheme and host allow-lists. This deliberately changes the previous semantics: for `jar:http://host/...` to be accepted, both `jar` and `http` must appear in the allow-list, and the inner host must satisfy the host allow-list. An alternative considered was the grammar documented by [`XMLConstants`](https://docs.oracle.com/en/java/javase/25/docs/api/java.xml/javax/xml/XMLConstants.html), where tokens like `jar:file` or `jar:http` would explicitly allow specific inner schemes. That grammar is documented but not honored by the JDK reference implementation: `jdk.xml.internal.SecuritySupport.checkAccess` (verified on JDK 8, 17 and 25) strips the `jar:` prefix and matches only the inner scheme as a bare token, so a `jar:http` entry in the allow-list never matches anything. Aligning with the documented spec would have added marginal expressiveness at the cost of diverging from what JDKs actually do.
The classical inversion bug. 😉
garydgregory
requested changes
May 12, 2026
Member
garydgregory
left a comment
There was a problem hiding this comment.
Thank you for the PR @ppkarwasz
- I think I saw some failures fly by on Java 25 due, possibly, to different Java versions throwing different exceptions for missing hosts.
- I left comments scattered throughout.
Thank you!
garydgregory
added a commit
that referenced
this pull request
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #633 by recursively validating the inner URL of a jar: URL against the same scheme and host allow-lists.
This deliberately changes the previous semantics: for
jar:http://host/...to be accepted, bothjarandhttpmust appear in the allow-list, and the inner host must satisfy the host allow-list.An alternative considered was the grammar documented by
XMLConstants, where tokens likejar:fileorjar:httpwould explicitly allow specific inner schemes. That grammar is documented but not honored by the JDK reference implementation:jdk.xml.internal.SecuritySupport.checkAccess(verified on JDK 8, 17 and 25) strips thejar:prefix and matches only the inner scheme as a bare token, so ajar:httpentry in the allow-list never matches anything. Aligning with the documented spec would have added marginal expressiveness at the cost of diverging from what JDKs actually do.